package com.example.mountainwalker.mapper;

import com.example.mountainwalker.entity.GroupTourInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GroupTourMapper {
    @Select("SELECT * FROM GroupTour")
    List<GroupTourInfo> getGroupTourList();

    @Select("SELECT * FROM GroupTour WHERE GroupTourID = #{id}")
    GroupTourInfo getGroupTourById(Integer id);

    @Delete("DELETE FROM GroupTour WHERE GroupTourID = #{id}")
    int deleteGroupTourById(Integer id);

    @Insert("INSERT INTO GroupTour(GroupTourID, GroupTourName, RegionID, TravelAgencyID, ScenicSpotID, " +
            "GroupTourIntroduction, PrincipalName, PrincipalPhone, PrincipalEmail, " +
            "StartDate, EndDate, AssemblyTime, AssemblyPlace, RecruitmentNumber, " +
            "GroupTourPrice, ReleaseDate) " +
            "VALUES(#{groupTourID}, #{groupTourName}, #{regionID}, #{travelAgencyID}, #{scenicSpotID}, " +
            "#{groupTourIntroduction}, #{principalName}, #{principalPhone}, #{principalEmail}, " +
            "#{startDate}, #{endDate}, #{assemblyTime}, #{assemblyPlace}, " +
            "#{recruitmentNumber}, #{groupTourPrice}, #{releaseDate})")
    int addGroupTour(GroupTourInfo groupTourInfo);


    @Update("UPDATE GroupTour SET " +
            "GroupTourName = #{groupTourName}, " +
            "RegionID = #{regionID}, " +
            "TravelAgencyID = #{travelAgencyID}, " +
            "ScenicSpotID = #{scenicSpotID}, " +
            "GroupTourIntroduction = #{groupTourIntroduction}, " +
            "PrincipalName = #{principalName}, " +
            "PrincipalPhone = #{principalPhone}, " +
            "PrincipalEmail = #{principalEmail}, " +
            "StartDate = #{startDate}, " +
            "EndDate = #{endDate}, " +
            "AssemblyTime = #{assemblyTime}, " +
            "AssemblyPlace = #{assemblyPlace}, " +
            "RecruitmentNumber = #{recruitmentNumber}, " +
            "GroupTourPrice = #{groupTourPrice}, " +
            "ReleaseDate = #{releaseDate} " +
            "WHERE GroupTourID = #{groupTourID}")
    int updateGroupTour(GroupTourInfo groupTourInfo);

}
